package com.wzw.springboot.principle.annotation;

import com.wzw.springboot.principle.use.batch.ColumnHandler;
import com.wzw.springboot.principle.use.batch.ColumnMapped;
import org.reflections.Reflections;
import org.reflections.scanners.Scanners;
import org.reflections.util.ConfigurationBuilder;

import java.util.Set;

/**
 * @author Wangzhiwen
 */
public class Parse {

    public static void main(String[] args) {
        String basePackage = "com.wzw.springboot.principle.use.batch.simple";
        // 框架反射获取路径下满足条件的类
        ConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
                .forPackages(basePackage).addScanners(Scanners.values());
        Reflections reflections = new Reflections(configurationBuilder);
        // 获取所有标记了特定注解的类
        Set<Class<?>> annotatedWith = reflections.getTypesAnnotatedWith(ColumnMapped.class);
        for (Class<?> clazz : annotatedWith) {
            String withInsert = ColumnHandler.mappedWithInsert(clazz);
            System.out.println(withInsert);
        }
    }

}
